package com.colorlight.cloud.complete.entity.instructions;

import com.colorlight.cloud.complete.api.CompleteEntityScheduleActions;
import com.colorlight.iot.proto.complete.instruction.CompleteInstruction;
import com.google.protobuf.ByteString;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

/**
 * 重启设备
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Slf4j
public class Reboot implements CompleteEntityScheduleActions {

    @Data
    @NoArgsConstructor
    @Builder
    public static class InputMsg implements Serializable {
    }

    @Data
    @NoArgsConstructor
    @Builder
    public static class OutputMsg implements Serializable {
    }

    private InputMsg input;
    private OutputMsg output;

    @Override
    public ByteString objectConvertBytes() {
        final CompleteInstruction.Reboot.InputMsg.Builder inputMsg =
                CompleteInstruction.Reboot.InputMsg.newBuilder();
        final CompleteInstruction.Reboot.Builder builder =
                CompleteInstruction.Reboot.newBuilder();
        builder.setInput(inputMsg);
        return builder.build().toByteString();
    }

    @Override
    public Reboot byteConvertObject(ByteString bytes) {
        this.setOutput(new OutputMsg());
        return this;
    }
}

